<template>
	<div class="orderDetails">
    <div :style="{
      'background':' #f2f2f2',
      'height': '32px',
      'line-height': '32px',
      'padding-left': '20px',
      'margin-bottom': '20px',
    }">销售订单</div>
		<FormPanel
      ref="formPanel"
		  :list="formList"
		  :cols="3"
		  labelWidth='90'
		  :isSubmitBtn="false"
		  :formType="type"
      @formChange="formChangeHandle"
		/>
    <!-- <div :style="{
      'background':' #f2f2f2',
      'height': '32px',
      'line-height': '32px',
      'padding-left': '20px',
      'margin-bottom': '20px',
    }">开票人信息</div>
		<FormPanel
      ref="formPanelA"
		  :list="formListA"
		  :cols="3"
		  labelWidth='90'
		  :isSubmitBtn="false"
		  :formType="type"
      @formChange="formChangeHandleA"
		/> -->
    <div :style="{
      'background':' #f2f2f2',
      'height': '32px',
      'line-height': '32px',
      'padding-left': '20px',
      'margin-bottom': '20px',
    }">服务项目</div>
    <FilterTable
	      ref="table"
        :dataSource="serviceSource"
	      :columns="columns"
        :onRowSelectChange="selectChange"
	      :onColumnsChange="columns => this.columns = columns"
	    >
      <template slot="controls" v-if="type !== 'show'">
        <el-button type="primary" @click="addHandle">新增</el-button>
        <el-button :disabled="isChoice" type="primary" @click="isChoice?'':deleteMoreHandle">删除</el-button>
      </template>
    </FilterTable>
    <!-- 合计区域 -->
    <FormPanel
      :style="{
        'margin':'40px'
      }"
      ref="formPanelB"
      :list="formListB"
      :cols="3"
      :formType="type"
      labelWidth="90"
      :isSubmitBtn="false"
      @formChange="formChangeHandleB"
    />
		<div class="upWard" :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }">
      <el-button v-if="type=='add'||type=='edit'" size="small" type="primary" @click="saveDialog">保存</el-button>
			<el-button size="small" type="primary" @click="closeDialog">返回</el-button>
		</div>
    <!-- 新增产品选择 -->
    <BaseDialog
      :visible.sync="visibleProduct"
      title="产品选择"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <productSelection type="edit" :modifyType="modifyType" :rowData="formData" @close="closeHandler22" @close2="closeHandler2" />
    </BaseDialog>
    <!-- 配车,拿到VIN -->
    <BaseDialog
      :visible.sync="visibleConfirmCar"
      title="VIN选择"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <ConfirmCar :rowData="formData" @close="closeConfirmCar" />
    </BaseDialog>

    <!-- 新增维护项目费用 -->
    <BaseDialog
      :visible.sync="visibleService"
      title="维护项目费用"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <serviceSelection @close="closeServiceDialog" />
    </BaseDialog>
    <!-- 开票人信息选择 -->
    <BaseDialog
      :visible.sync="visibleCustomer"
      title="开票人信息选择"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <selectCustomer @close="closeCustomerDialog" />
    </BaseDialog>
	</div>
</template>

<script>
import { idQueryOrders } from '@/api/retail/salesmanage/salesorder';
import { getlistAllData} from "@/api/common/org/dealerCompany";
import { dictionary } from '@/utils/dictMixin'; //数据字典
import ConfirmCar from '../confirmcar/clueSelection';
import serviceSelection from '../salesordermanage/serviceSelection';
import productSelection from '../salesordermanage/productSelection';
import selectCustomer from '../salesordermanage/selectCustomer'
import moment from 'moment'
export default {
	name: 'orderDetails',
  mixins: [dictionary],
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    },
    baseData: { // 客户订单功能页面过来的才有add/edit/show
      type: Array,
      default: () => ([])
    },
    type: {
      type: String,
      default: 'show'
    },
  },
  components: {
    ConfirmCar,
    serviceSelection,
    productSelection,
    selectCustomer
  },
	data (){
		return {
      formList: this.createFormList(),
      //formListA: this.createFormListA(),
      formListB: this.createFormListB(),
      columns: this.createFilterColumns(),
      serviceSource: [], //默认的赋值
      // white2NumList: ['provinceId', 'cityId', 'districtId'],
      province: [],
      city: [],
      district: [],
      listAllData: [],
      visibleConfirmCar: false, // 配车窗口
      formData: {},
      currentVsStockId: '',
      saveData: '',
      saveDataA: '',
      saveDataB: '',
      visibleService: false, // 新增服务项目
      modifyType: true, // 该页面默认为修改
      visibleProduct: false, // 选择产品
      isChoice: true, // 选中数据false，未选中数据true
      visibleCustomer: false,
      selectCustomerId: '' // 当前所选customerId
		}
	},
  mounted() {
    this.init();
  },
	methods: {
    init (){
      console.log(this.type,'服务项目',this.rowData)
      let { baseData } = this
      if (this.type === 'add' || this.type === 'edit' || JSON.stringify(baseData)!='[]') {
        this.formData = JSON.parse(JSON.stringify(this.rowData))
        this.formListFill(this.rowData)
        //this.formListAFill(this.rowData)
        // 服务项目填入
        this.serviceSource = JSON.parse(JSON.stringify(this.rowData.serviceItem));
        this.amountAmount()
      }
      this.getorders(this.rowData['soVinId'])
    },
    formListFill (data, ifNeed = false) {
      this.selectCustomerId = data['customerId']
      this.formList.forEach(item => {
        if (item.fieldName == 'colorName'){
          item.initialValue = data['color']
        }
        //  else if(item.fieldName == 'salesVin') {
        //   item.initialValue = data['salesVin']
        // }
        else if(item.fieldName == 'directivePrice'){
          console.log(data,"谭思军")
          // 从外层来的叫'price'，从内层窗口组件来的叫'oemDirectivePrice',销售明细页面叫'directivePrice'
          item.initialValue = data['price'] || 12
        } else if (item.fieldName == 'adderss') {
          item.initialValue = data['address'] //
        } else {
          item.initialValue = data[item.fieldName]
        }
      })
      // 客户编号
      this.formList.find(item => item.fieldName === 'customerNo').initialValue = this.baseData.find(item => item.fieldName==='customerNo').initialValue
      this.formList.find(item => item.fieldName === 'soNo').initialValue = this.baseData.find(item => item.fieldName==='soNo').initialValue

      // 重计算
      ifNeed ? this.amountAmount() : ''
    },
    formListAFill (rowData) {
      if (rowData['customerType'] == 15231001) {
        this.formListA = this.createFormListA(true)
      } else if (rowData['customerType'] == 15231003) {
        this.formListA = this.createFormListA(false)
      }
      this.formListA.forEach(item => {
        if (item.fieldName == 'birthday') {
          item.initialValue = this.preDateHandler(rowData['birthday'],'YYYY-MM-DD')
        } else {
          item.initialValue = rowData[item.fieldName]
        }
      })
    },
    formListBFill () {
      let { rowData } = this
      this.formListB.forEach(item => {
        item.initialValue = rowData[item.fieldName]
      })
    },
    async getorders (row){
      let { provinceChange, cityChange, baseData } = this
      if (this.type == 'show'&&row&&JSON.stringify(baseData)=='[]') {
        let res = await idQueryOrders(row);
        // console.log(res)
        if(res.resultCode == 200){
          console.log(res.data,"服务数据--小菜")
          res.data.deliveringDate = res.data.deliveringDate == null? '': this.preDateHandler(res.data.deliveringDate, 'YYYY-MM-DD')
          this.formList.forEach(x => x.initialValue = res.data[x.fieldName] );
          this.serviceSource = res.data.soServiceVOList
          //this.formListAFill(res.data)
        }
      }
      this.fillAddress()
    },
    // 省市县区
    fillAddress () {
      getlistAllData().then(res=>{
        this.listAllData=res.data
        this.province = []
        this.listAllData.forEach(x=>{
          let proviceValue = this.formList.find(x => x.fieldName === 'provinceId').initialValue
          let cityValue = this.formList.find(x => x.fieldName === 'cityId').initialValue
          // 筛选省
          if(x.parentRegionId == null){
            this.province.push({text:x.regionName,value:x.regionId})
          }
          // 筛选市
          if(proviceValue && x.parentRegionId == proviceValue){
            this.city.push({text:x.regionName,value:x.regionId})
          }
          // 筛选区
          if(cityValue && x.parentRegionId == cityValue ){
            this.district.push({text:x.regionName,value:x.regionId})
          }
        })
        this.formList.find(item => item.fieldName === 'provinceId').itemList = _.uniqBy(this.province,'value')
        this.formList.find(item => item.fieldName === 'cityId').itemList = _.uniqBy(this.city,'value')
        this.formList.find(item => item.fieldName === 'districtId').itemList = _.uniqBy(this.district,'value')
      })
    },
		createFormList (){
			return [
				{
          type: 'INPUT',
          label: '客户订单号',
          fieldName: 'soNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '销售订单号',
          fieldName: 'viNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '客户编号',
          fieldName: 'customerNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'productName',
          readonly: true,
          placeholder: '请选择',
          unitRender: () => {
            return <el-button icon="el-icon-search" onClick={this.productSearch}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'productCode',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '品牌',
          fieldName: 'brandName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车系',
          fieldName: 'seriesName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车型',
          fieldName: 'modelName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配置',
          fieldName: 'packageName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '颜色',
          fieldName: 'colorName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: 'VIN号',
          fieldName: 'salesVin',
          placeholder: '',
          unitRender: () => {
            return <el-button icon="el-icon-search" onClick={this.vehicleHandle}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '销售指导价',
          fieldName: 'directivePrice',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '预交车日期',
          fieldName: 'deliveringDate',
          placeholder: '',
        },
        {
          type: 'INPUT',
          label: '销售单价',
          fieldName: 'vehiclePrice',
          placeholder: '',
          onInput: (e)=>{
            // 强制重写，不然合计金额渲染不同步
            this.formList.find(item => item.fieldName === 'vehiclePrice').initialValue = Number(e) || 0;
            this.amountAmount();
          }
        },
        {
          type: 'SELECT',
          label: '车辆使用地址',
          fieldName: 'provinceId',
          placeholder: '选择省份',
          itemList: [],
          change: val => {
            let city=[]
            if(val == 3662){
              this.formList.find(x => x.fieldName === 'cityId').itemList=[{text:"台湾",value:3662}]
              this.formList.find(x => x.fieldName === 'districtId').itemList=[{text:"台湾",value:3662}]
            }else if(val == 3663){
              this.formList.find(x => x.fieldName === 'cityId').itemList=[{text:"香港",value:3663}]
              this.formList.find(x => x.fieldName === 'districtId').itemList=[{text:"香港",value:3663}]
            }else if(val == 3664){
              this.formList.find(x => x.fieldName === 'cityId').itemList=[{text:"澳门",value:3664}]
              this.formList.find(x => x.fieldName === 'districtId').itemList=[{text:"澳门",value:3664}]
            }
            this.formList.find(x => x.fieldName === 'cityId').initialValue=''
            this.formList.find(x => x.fieldName === 'cityId').itemList= []
            this.formList.find(x => x.fieldName === 'districtId').initialValue=''
            this.formList.find(x => x.fieldName === 'districtId').itemList= []
            this.listAllData.forEach(x=>{
              // 筛选省
              if(x.parentRegionId == val){
                city.push({text:x.regionName,value:x.regionId})
                this.formList.find(x => x.fieldName === 'cityId').itemList=_.uniqBy(city,'value')
              }
            })
          },
        },
        {
          type: 'SELECT',
          label: '',
          fieldName: 'cityId',
          placeholder: '选择城市',
          itemList: [],
          change: val =>{
            let county=[]
            this.formList.find(x => x.fieldName === 'districtId').initialValue=''
            this.formList.find(x => x.fieldName === 'districtId').itemList= []
            this.listAllData.forEach(x=>{
              // 筛选省
              if(x.parentRegionId == val){
                county.push({text:x.regionName,value:x.regionId})
                this.formList.find(x => x.fieldName === 'districtId').itemList=_.uniqBy(county,'value')
              }
            })
          }
        },
        {
          type: 'SELECT',
          label: '',
          fieldName: 'districtId',
          itemList: [],
          placeholder: '选择区/县',
        },
        {
          type: 'SELECT',
          label: '销售类型',
          fieldName: 'saleType',
          placeholder: '',
          itemList: this.createDictList('2013')
        },
        {
          type: 'INPUT',
          label: '备注',
          fieldName: 'remark',
          placeholder: '',
        },
      ]
    },
    createFormListA (isPersonal = true) {
      // 个人/公司
      let part1 = [
      {
        type: 'SELECT',
        label: '客户类型',
        fieldName: 'customerType',
        placeholder: '',
        initialValue: isPersonal ? 15231001 : 15231003,
        itemList: this.createDictList('1523'),
        disabled: true,
        change: (e) => {
          let flag = e == 15231001 ? true : false
          this.formListA = this.createFormListA(flag)
        }
      },
      {
        type: 'INPUT',
        label: '开票名称',
        fieldName: 'customerName', // invoiceName => customerName
        placeholder: '',
        readonly: true,
        initialValue: '',
        unitRender: () => {
          return <el-button icon="el-icon-search" onClick={this.invoiceLinkManSearch}></el-button>;
        }
      }]
      // 个人
      let part2 = [{
        type: 'INPUT',
        label: '开票手机',
        fieldName: 'mobilePhone',
        placeholder: '',
        initialValue: '',
        // labelWidth:'150',
        // style: {'display':'block','width': 'auto','margin-left':'100px'},
        disabled: true
      }]
      // 个人/公司
      let part3 = [{
        type: 'INPUT',
        label: '开票电话',
        fieldName: 'phone',
        placeholder: '',
        initialValue: '',
        disabled: true
      },
      {
        type: 'SELECT',
        label: '证件类型',
        fieldName: 'ctCode',
        placeholder: '',
        initialValue: '',
        disabled: true,
        itemList: this.createDictList('1508') // 原'1058'修改为'7035' 再改为'1508'
      },
      {
        type: 'INPUT',
        label: '证件号码',
        fieldName: 'certificateNo' ,
        placeholder: '',
        initialValue: '',
        disabled: true
      }]
      // 公司
      let part4 = [{
        type: 'INPUT',
        label: '开票联系人',
        fieldName: 'invoiceLinkMan',
        initialValue: '',
        disabled: true,
        placeholder: '',
      },
      {
        type: 'INPUT',
        label: '开票联系人手机',
        fieldName: 'mobilePhone',
        labelWidth:'150',
        style: {'display':'block','width': 'auto','margin-left':'100px'},
        initialValue: '',
        disabled: true,
        placeholder: ''
      }]
      // 个人/公司
      let part5 = [{
        type: 'SELECT',
        label: '性别',
        fieldName: 'gender',
        placeholder: '',
        initialValue: '',
        disabled: true,
        itemList: this.createDictList('1002')
      },
      {
        type: 'INPUT',
        label: '生日',
        fieldName: 'birthday',
        placeholder: '',
        initialValue: '',
        disabled: true
      },
      {
        type: 'SELECT',
        label: '行业类型',
        fieldName: 'industryType',
        placeholder: '',
        initialValue: '',
        disabled: true,
        itemList: this.createDictList('7030')
      },
      {
        type: 'INPUT',
        label: '开票地址',
        fieldName: 'address',
        placeholder: '',
        initialValue: '',
        disabled: true
      }]
      let resultList = isPersonal ? [...part1, ...part2, ...part3, ...part5] : [...part1, ...part3, ...part4, ...part5]
      //开票信息
      console.log('createFormListA',resultList)
      return resultList
    },
    createFormListB () {
      return [
        {
          type: 'INPUT',
          label: '服务项目金额',
          fieldName: 'currentServiceTotal',
          placeholder: '',
          offsetLeftCols: 1,
          labelWidth: '150',
          initialValue: 0,
          style: {'display':'block','width': 'auto','margin-left':'100px'},
          disabled: true
        },
        {
          type: 'INPUT',
          label: '销售订单总金额',
          fieldName: 'currentTotal',
          placeholder: '',
          labelWidth: '150',
          initialValue: 0,
          style: {'display':'block','width': 'auto','margin-left':'100px'},
          disabled: true
        },
      ]
    },
    createFilterColumns () {
      return [
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 90,
          fixed: 'left',
          render: (props, h) => {
            if(this.type != 'show'){
              return (
                <div>
                  <el-button size="mini" type="text" onClick={() => this.deleteSingleService(props.row)}>
                    删除
                  </el-button>
                </div>
              );
            }
          }
        },
        {
	        title: '序号',
	        dataIndex: 'index',
	        width: 80,
	        sorter: true,
	        render: props => {
	          return <span>{props.row.index + 1}</span>;
	        }
        },
	      {
	        title: '项目代码',
          dataIndex: 'serviceCode',
	        filterType: 'input',
	      },
	      {
	        title: '项目名称',
          dataIndex: 'serviceName',
	        filterType: 'input',
	      },
	      {
	        title: '费用类型',
          dataIndex: 'serviceType',
	        filterType: 'input',
          filterItems: this.createDictList('1421'),
          render: props => {
            return <span> { this.preDictHandler(props.row.serviceType,'1421')} </span>
          }
	      },
	      {
	        title: '费用金额',
          dataIndex: 'actualIncurredAmount',
	        filterType: 'input',
	      },
      ]
    },
    createTotalColumns () {
      return []
    },
    // 选择产品
    productSearch () {
      console.log('选择产品')
      this.visibleProduct = true
    },
    // 选择开票联系人
    invoiceLinkManSearch () {
      console.log('选择开票联系人')
      this.visibleCustomer = true
    },
    // 配车-获取vin号
    vehicleHandle () {
      console.log('选择vin', this.formData)
      this.visibleConfirmCar = true
    },
    closeConfirmCar (isOpen = false, val) { // 配车dialog关闭
      console.log('closeConfirmCar', val)
      this.visibleConfirmCar = false
      // 有新增数据
      if (val && val.length > 0) {
        // 当前所选择的VIN、vsStockId
        this.formList.find(item => item.fieldName == 'salesVin').initialValue = val[0].vin
        this.currentVsStockId = val[0].vsStockId
        console.log('surpurise', this.formList)
      }
    },
    closeServiceDialog(val=false,data){ // 服务项目dialog关闭
      this.visibleService = false
      console.log('closeServiceDialog',data)
      // 有新增数据
      if (data && data.length > 0) {
        data['birthday'] = this.preDateHandler(data['birthday'],'YYYY-MM-DD')
        this.$refs.table.$refs.pageTable.EXECUTE_INSERT(data)
        // this.$refs.table.$refs.pageTable.SET_DISABLE_SELECT(data)
        console.log('closeServiceDialog',this.serviceSource)
      }
      this.amountAmount()
    },
    closeCustomerDialog(val=false,data){
      this.visibleCustomer = false
      if (data && JSON.stringify(data)!='{}') {
        this.selectCustomerId = data['customerId']
        if (data['customerType'] == 15231001) {
          this.formListA = this.createFormListA(true)
        } else if (data['customerType'] == 15231003) {
          this.formListA = this.createFormListA(false)
        }
        this.formListA.forEach(item => {
          if (item.fieldName == 'colorName') {
            item.initialValue = data['color']
          } else {
            item.initialValue = data[item.fieldName]
          }
        })
      }
    },
		// changeHandle(val){ //点击保存按钮出发的事件
    //   console.log('表单面板的数据：', val);
    // },
    // changeHandleA(val) {
    //   console.log('表单面板的数据A：', val);
    // },
    addHandle () {
      console.log('新增服务项目')
      this.visibleService = true
    },
    deleteMoreHandle() { // 服务项目的批量删除
      console.log('批量删除服务项目')
      // 重计算
      this.amountAmount()
    },
    deleteSingleService (row) { // 服务项目的单个删除
      this.$refs.table.$refs.pageTable.EXECUTE_DELETE([row])
      // this.serviceSource = this.serviceSource.filter( item => item.$index !== row.$index)
      this.amountAmount()
    },
    // deleteHandle () {
    //   console.log('删除服务项目')
    // },
    formChangeHandle(val) {
      this.saveData = _.cloneDeep(val);
    },
    formChangeHandleA (val) {
      console.log('saveDataA',val)
      this.saveDataA = _.cloneDeep(val);
    },
    formChangeHandleB (val) {
      this.saveDataB = _.cloneDeep(val);
    },
    // 计算金额
    amountAmount () {
      let [currentServiceTotal, currentTotal] = [0, 0]
      let vehiclePrice = this.formList.find(item => item.fieldName === 'vehiclePrice')['initialValue'] || 0
      // 计算总金额
      let serviceSourceLength = this.serviceSource.length
      for(let i = 0;i<serviceSourceLength;i++) {
        currentServiceTotal += this.serviceSource[i]['actualIncurredAmount']
      }
      // 车辆价格 + 服务价格
      currentTotal = Number(vehiclePrice) + currentServiceTotal
      this.formListB.find(item => item.fieldName === 'currentServiceTotal').initialValue = currentServiceTotal
      this.formListB.find(item => item.fieldName === 'currentTotal').initialValue = currentTotal
      console.log('amountAmount',this.formListB,currentTotal, vehiclePrice, currentServiceTotal)
    },
    selectChange (rows){ //选中时触发的函数
      console.log(rows)
      this.selectedRows = rows;
      this.isChoice = this.selectedRows.length > 0? false: true;
    },
    saveDialog () { // 保存-返回上一层
      this.$refs.formPanel.SUBMIT_FORM();
      // this.$refs.formPanelA.SUBMIT_FORM();
      this.$refs.formPanelB.SUBMIT_FORM();
      this.saveData['vin'] = this.saveData['salesVin']
      this.saveData['deliveringDate'] = new Date(this.saveData['deliveringDate']).getTime()
      this.saveData['color'] = this.saveData['colorName']
      this.saveData['customerId'] = this.selectCustomerId
      // this.saveDataA['address'] = this.saveDataA['address']
      // this.saveDataA['invoiceLinkMan'] = this.saveDataA['contactName']
      let giveOutObj = {
        ...this.saveData,
        // ...this.saveDataA,
        ...this.saveDataB,
        vsStockId: this.currentVsStockId,
        serviceItem: this.serviceSource
      }
      console.log('giveOutObj',giveOutObj)
      this.$emit('close', false, giveOutObj);
    },
    closeDialog (){ //返回上层
      this.$emit('close', false);
    },

    closeHandler22 (val){
      this.visibleProduct = val;
    },
    closeHandler2 (val, data){
      this.visibleProduct = val;
      let productData = data[0];
      console.log(productData)
      // 车辆数据重选更新原数据
      for (let item in this.formData) {
        if (item === 'price') {
          // 从外层来的叫'price'，从内层窗口组件来的叫'oemDirectivePrice',销售明细页面叫'directivePrice'
          this.formData[item] = productData['oemDirectivePrice'] || 0
        } else if (item === 'deliveringDate') {
          this.formData['deliveringDate'] = new Date().getTime()
        } else if (item === 'vehiclePrice'){
          this.formData[item] = productData['oemDirectivePrice'] || productData['oemDirectivePrice'] || 0
        }else{
          this.formData[item] = productData[item]
        }
      }
      console.log(this.formData)
      // 车辆数据重选更新界面
      this.formListFill(this.formData, true)
      // let newProduct = {
      //   // index: _index,
      //   brandId: productData.brandId,
      //   viNo: this.dataSource[_index].viNo,
      //   soNoId: this.recordId || '',
      //   vin: '',
      //   remark: '',
      //   invoiceName: productData.invoiceName,
      //   invoiceLinkMan: productData.invoiceLinkMan,
      //   invoiceMobile: productData.invoiceMobile,
      //   invoiceAddress: productData.invoiceAddress,
      //   productCode: productData.productCode,
      //   brandName: productData.brandName,
      //   seriesName: productData.seriesName,
      //   modelName: productData.modelName,
      //   packageName: productData.packageName,
      //   color: productData.color,
      //   deliveringDate: new Date().getTime(),
      //   vehiclePrice: productData.vehiclePrice || productData.oemDirectivePrice || 0,
      //   dispatchedStatus: 14141001, // 未配车
      //   modelId: productData.modelId, //车型Id
      //   packageId: productData.packageId, //配置Id
      //   price: productData.oemDirectivePrice, //价格销售指导价
      //   productName: productData.productName, // 产品名称
      //   productId: productData.productId, //产品ID不能为空
      //   seriesId: productData.seriesId, //车系Id
      //   showService: this.dataSource[_index].showService,
      //   serviceItem: this.dataSource[_index].serviceItem,
      // }
    },
    // 字典数据使用前预处理
    preDictHandler(val, code){
      let resultText = val && String.prototype.includes.call(val, code) ? this.createDictText(val, code) : val;
      return resultText;
    },
    // 日期预处理
    preDateHandler(val, formatCode='YYYY-MM-DD HH:mm:ss') {
      let resultDate = val ? moment(Number(val)).format(formatCode) : val;
      if ((resultDate == 'Invalid date' || resultDate == 'Invalid Date') && val) {
        resultDate = moment(val).format(formatCode)
      }
      return resultDate;
    },
	}

}
</script>

<style scoped="scoped" lang="less">
.upWard{
	margin-top: 15px;
	text-align: center;
}
</style>
